<?php
	!defined('DYHB_PATH')&& exit;
	class PictureController extends InitController{
		public function upload(){
			if($GLOBALS['___login___']==false){
				$this->E('你还没有登陆');
			}
			$this->assign('title','上传图片');
			$this->display();
		}
		public function upload_deal(){
			require_once(BLOG_PATH.'/common/upfile.php');
			if($GLOBALS['___login___']==false){
				$this->E('你还没有登陆');
			}
			if(!empty($_POST['sub_img'])){
				$fileField=$_FILES['upfile'];
				$name="";
				if(!empty($_POST['img_name'])){
					$name=$_POST['img_name'];
				}else{
					$name=time();
				}
				$dir=BLOG_PATH."/data/upload";
				$ext=substr($fileField['name'],strrpos($fileField['name'],'.'));
				$oUpload=new upLoad($fileField,1024*1024,$dir,$name);
				$msg=$oUpload->uploading();
				$GLOBALS['IMG_PATH']=$dir.'/'.$name.$ext;
				if($msg==false){
					$this->S('图片上传成功');
				}else{
					$this->E($msg);
				}
			}else{
				$this->E('上传文件错误');
			}
		}
	}
?>